use lettre::{Message, SmtpTransport, Transport};
use lettre::transport::smtp::authentication::Credentials;

fn main(){
    send_email("123");
    println!("123");
}


// 发送邮件
fn send_email(body: &str) -> Result<(), lettre::transport::smtp::Error> {
    let email = Message::builder()
        .from("cstslswust@163.com".parse().unwrap())
        .to("cstslswust@163.com".parse().unwrap())
        .subject("Natapp 服务日志")
        .body(body.to_string())
        .unwrap();

    let creds = Credentials::new("cstslswust@163.com".to_string(),"KNQ5M3AnG87fnvwy".to_string());

    let mailer = SmtpTransport::relay("smtp.163.com")
        .unwrap()
        .credentials(creds)
        .build();

    mailer.send(&email).unwrap();
    Ok(())
}

